<template>
  <div class="mui-numbox" data-numbox-min="1">
    <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
    <input
      id="test"
      class="mui-input-numbox"
      type="number"
      :value="initCount"
      ref="number"
      @change="countChanged"
      readonly
    >
    <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
  </div>
</template>
<script>
// 引入mui实例对象
import mui from "../../lib/mui/js/mui.min.js";
export default {
  mounted() {
    //  mui在mui.init()中会自动初始化基本控件,但是 动态添加的Numbox组件需要手动初始化

    // mui(Selector).numbox()
    mui(".mui-numbox").numbox();
  },
  methods:{
      //购物车商品数量改变
      countChanged(){
          this.$store.commit("updateGoodsCount",{id:this.goodId,count:this.$refs.number.value})
      }
  },
  props:["initCount",'goodId']
}; 

</script>
<style lang="scss" scoped>
</style>
